package com.heima.comment.controller;

import com.heima.comment.dto.CommentDto;
import com.heima.comment.dto.CommentLikeDto;
import com.heima.comment.dto.CommentSaveDto;
import com.heima.comment.service.IApCommentService;
import com.heima.common.dto.ResponseResult;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {
    @Autowired
    private IApCommentService commentService;


    @PostMapping("/save")
    @ApiOperation(value = "saveComment", notes = "发表评论")
    @ApiImplicitParam(name = "dto", dataType = "CommentSaveDto", required = true)
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto) {
        return commentService.saveComment(dto);
    }


    @PostMapping("/load")
    @ApiOperation(value = "loadComment", notes = "加载评论列表")
    @ApiImplicitParam(name = "dto", dataType = "CommentDto", required = true)
    public ResponseResult loadComment(@RequestBody CommentDto dto) {
        return commentService.loadComment(dto);
    }

    @PostMapping("/like")
    @ApiOperation(value = "likeComment", notes = "点赞评论")
    @ApiImplicitParam(name = "dto", dataType = "CommentDto", required = true)
    public ResponseResult likeComment(@RequestBody CommentLikeDto dto){
        return commentService.likeComment(dto);
    }
}
